<template>
  <div class="page">
    <van-nav-bar
      :z-index="999"
      :fixed="true"
      left-arrow
      @click-left="onClickLeft"
      :placeholder="true"
      title="我的账户"
    ></van-nav-bar>

    <div class="my-current">
      <p>当前余额</p>
      <div>
        ￥
        <span>{{ individualAccount.je }}</span>
      </div>
      <div class="my-top-up">
        <div @click="href('/TopUp', '1')" class="top-up">充值</div>
        <div @click="href('/TopUp', '2')" class="my-embody">提现</div>
      </div>
      <!-- 消费记录 -->
      <div class="my-bill">
        <div class="bill-state">
          <p>用途</p>
          <p>金额(元)</p>
          <div>时间</div>
        </div>
        <div v-for="(item, index) in bill" :key="index" class="bill-list">
          <p>{{ item.orderstatus }}</p>
          <p>{{ item.money }}</p>
          <div>{{ item.ordertime }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { individualAccount } from "../../assets/js/api/user";
export default {
  name: "MyAccount",
  data: function() {
    return {
      // 假数据
      individualAccount: {},
      bill: []
    };
  },
  mounted() {
    // basicInformation().then(res => {
    //   console.log(res.data);
    // });
    individualAccount().then(res => {
      // console.log(res);
      this.individualAccount = res.data;
      this.bill = res.data.orderInfo;
      // console.log(this.bill);
    });
  },

  methods: {
    href(url, type) {
      this.$router.push({ path: `${url}/${type}` });
    },
    onClickLeft() {
      this.$router.go(-1);
    }
  },
  created() {
    let dsBridge = require("dsbridge");
    dsBridge.call("goBack", "", function() {
      history.go(-1);
    });
  }
};
</script>

<style></style>
